package com.zhangzhan.controller;

import com.zhangzhan.constants.SystemConstants;
import com.zhangzhan.domain.commcon.ResponseResult;
import com.zhangzhan.domain.entity.Comment;
import com.zhangzhan.service.CommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 张一恒
 * @version 1.0
 */
@RestController
@RequestMapping("/comment")
@Api(tags = "评论",description = "评论相关接口")
public class CommentController {

    @Autowired
    CommentService commentService;

    //查询用户评论
    @GetMapping("/commentList")
    public ResponseResult commentList(Long articleId,Integer pageNum,Integer pageSize){
        //调用service
       return commentService.commentList(SystemConstants.ARTICLE_COMMENT,articleId,pageNum,pageSize);
    }

    //评论接口
    @PostMapping
    public ResponseResult comment(@RequestBody Comment comment){
        return   commentService.commentSave(comment);
    }

    //友联评论查询接口
    @GetMapping("/linkCommentList")
    @ApiOperation(value = "友联评论接口",notes = "分页获取友联评论")
    @ApiImplicitParams({@ApiImplicitParam(name = "pageNum",value = "每页行数"),
                        @ApiImplicitParam(name = "pageSize",value = "每页展示数量")})
    public ResponseResult linkCommentList(Integer pageNum,Integer pageSize){
        return commentService.commentList(SystemConstants.LINK_COMMENT,null,pageNum,pageSize);
    }
}
